package view.render.monster
{
	import enums.main.UISize;
	
	import feathers.controls.Button;
	
	import model.vo.monster.MonsterListVo;
	
	import starling.display.Image;
	import starling.display.Sprite;
	
	import util.AtlasTextureGenerator;
	import util.FG2FUGenerator;
	
	
	/**
	 * 大型怪物简表
	 * @author £iang
	 * 
	 */	
	public class LTypeListItem extends Sprite
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** item按钮 */
		public var itemButton:Button;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		protected function initialize():void
		{
			itemButton = FG2FUGenerator.generateRoundRectButton(
				UISize.MONSTER_LIST_ITEM_W, UISize.MONSTER_LIST_ITEM_H,
				UISize.DPI_SCALE, 12, "small", true
			);
			itemButton.width = UISize.MONSTER_LIST_ITEM_W * UISize.DPI_SCALE;
			itemButton.height = UISize.MONSTER_LIST_ITEM_H * UISize.DPI_SCALE;
			itemButton.horizontalAlign = Button.HORIZONTAL_ALIGN_CENTER;
			itemButton.verticalAlign = Button.VERTICAL_ALIGN_MIDDLE;
			
			itemButton.iconPosition = "top";
			itemButton.gap = -1 * ( 1.5 - UISize.DPI_SCALE );
			itemButton.defaultLabelProperties.wordWrap = true;
			
			this.addChild( itemButton );
		}
		
		public function setData( monsterVo:MonsterListVo ):void
		{
			var tmpImage:Image = new Image( AtlasTextureGenerator.getMonsterTextureById(
				"l", monsterVo.monsterId
			));
			
			itemButton.label = monsterVo.chName + "\n" + monsterVo.jpName;
			tmpImage.width *= UISize.DPI_SCALE;
			tmpImage.height *= UISize.DPI_SCALE;
			itemButton.defaultIcon = tmpImage;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数 
		 * 
		 */		
		override public function dispose():void
		{
			itemButton.dispose();
			FG2FUGenerator.deepDisposeButtonComp( itemButton );
			itemButton = null;
			
			super.dispose();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function LTypeListItem()
		{
			super();
			initialize();
		}
	}
}